<template>
  <a-card class="info" title="入库单">
    <template slot="extra">
      <template v-if="model.auditStatus==0">
        <a-button
          class="ruleButton"
          :ghost="true"
          type="primary"
          icon="edit"
          @click="handleEdit(model)"
          :disabled="isDisabledAuth('erpPurchaseWarehouseWarrant:edit')"
        />
        <a-divider type="vertical"/>
        <a-popconfirm title="确定提交吗?" @confirm="() => handleSubmit(model.id)">
          <a-button type="primary" size="small" :disabled="isDisabledAuth('erpPurchaseWarehouseWarrant:submit')">提交</a-button>
        </a-popconfirm>
      </template>
      <!-- <template v-if="model.auditStatus==1">
          <a-button type="primary" size="small" @click="handleAudit(model.id)"  :disabled="isDisabledAuth('erpPurchaseWarehouseWarrant:audit')">审核</a-button>
        </template> -->
      <!-- <template v-if="model.auditStatus==2">
          <a-popconfirm title="确定反审吗?" @confirm="() => handleCounterTrial(model.id)">
            <a-button type="primary" size="small" :disabled="isDisabledAuth('erpPurchaseWarehouseWarrant:counterTrial')">反审</a-button>
          </a-popconfirm>
        </template> -->
    </template>
    <a-row type="flex" justify="center">
      <a-col :span="24">
        <erp-purchase-warehouse-warrant-form ref="realForm" :disabled="true" normal></erp-purchase-warehouse-warrant-form>
      </a-col>
    </a-row>
    <erp-purchase-warehouse-warrant-modal ref="modalForm" @ok="modalFormOk"></erp-purchase-warehouse-warrant-modal>
    <audit-modal ref="auditModal" @ok="modalFormOk"></audit-modal>
  </a-card>
</template>

<script>

  import { getAction } from '@/api/manage'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ErpPurchaseWarehouseWarrantForm from './modules/ErpPurchaseWarehouseWarrantForm'
  import ErpPurchaseWarehouseWarrantModal from './modules/ErpPurchaseWarehouseWarrantModal'
  import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'

  export default {
    name: 'ErpPurchaseWarehouseWarrantDetail',
    mixins: [JeecgListMixin, DisabledAuthFilterMixin],
    components: {
     ErpPurchaseWarehouseWarrantForm,
     ErpPurchaseWarehouseWarrantModal
    },
    data () {
      return {
         model: {},
        id: '',
        url: {
          queryById: '/api/erp/purchase/storehouse/erpPurchaseWarehouseWarrant/queryById',
          delete: '/api/erp/purchase/storehouse/erpPurchaseWarehouseWarrant/delete',
          submit: '/api/erp/purchase/storehouse/erpPurchaseWarehouseWarrant/submit',
          revoke: '/api/erp/purchase/storehouse/erpPurchaseWarehouseWarrant/revoke',
          counterTrial: '/api/erp/purchase/storehouse/erpPurchaseWarehouseWarrant/counterTrial',
          audit: '/api/erp/purchase/storehouse/erpPurchaseWarehouseWarrant/audit',
          overrule: '/api/erp/purchase/storehouse/erpPurchaseWarehouseWarrant/overrule'
        },
        confirmLoading: false,
        iconStyle: { 'font-size': '20px' }
      }
    },
    created() {
    },
    watch: {
      $route(to, from) {
        this.loadData();
      }
    },
    mounted() {
    },
    methods: {
      loadData() {
        const id = this.$route.params.id;
        getAction(this.url.queryById, { id }).then((res) => {
          if (res.success) {
            const model = res.result
            this.$refs.realForm.edit(model);
            this.model = model;
          }
        })
      }
    }
  }
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';

.info {
  /deep/ .ant-card-head-title{
    flex: none;
    margin-right: 20px;
  }
  /deep/ .ant-card-extra{
    flex: 1;
    float: left;
  }
}
</style>
